#ifndef CASSIOPEIAMAIN_H
#define CASSIOPEIAMAIN_H

class CassiopeiaMain;

#include "common.h"
#include "resource.h"
#include "Settings.h"
#include "Scheduler.h"
#include "DeskNotes.h"
#include "AdvancedShowDesktop.h"
#include "DeskTidy.h"
#include "DesktopPictureFrame.h"
#include "WindowTools.h"

#pragma region defines

#define TrayMenu_MenuFirstID						0

#define TrayMenu_AdvancedShowDesktop				(TrayMenu_MenuFirstID + 2)
#define TrayMenu_DeskNotes							(TrayMenu_MenuFirstID + 3)
#define TrayMenu_DeskTidy							(TrayMenu_MenuFirstID + 4)
#define TrayMenu_WindowTools							(TrayMenu_MenuFirstID + 8)
#define TrayMenu_SchedulerActive					(TrayMenu_MenuFirstID + 5)
#define TrayMenu_Separator1							(TrayMenu_MenuFirstID + 6)
#define TrayMenu_SchedulerSetAlert					(TrayMenu_MenuFirstID + 7)

#define TrayMenu_Separator5							(TrayMenu_MenuFirstID + 18)

#define TrayMenu_Close								(TrayMenu_MenuFirstID + 22)
#define TrayMenu_Separator7							(TrayMenu_MenuFirstID + 23)
#define TrayMenu_WindowsMinimizeAll					(TrayMenu_MenuFirstID + 24)
#define TrayMenu_WindowsRestoreAll					(TrayMenu_MenuFirstID + 25)

#define TrayMenu_DesktopPictureFrame				(TrayMenu_MenuFirstID + 27)

#define TrayMenu_LockDrivesFirstID					(TrayMenu_MenuFirstID + 80)
#define TrayMenu_LockDrivesLastID					(TrayMenu_LockDrivesFirstID + 20)


	
#pragma endregion

class CassiopeiaMain
{
public:
	~CassiopeiaMain();

	bool Close();
	static CassiopeiaMain* CreateInstance(HINSTANCE hInstance);
private:
	CassiopeiaMain(HINSTANCE hInstance);

	bool Close(bool postQuitMsg);

	void AddSystemMenuItems(HWND hWnd);
	void InitTrayMenu();
	void StartComponents(HINSTANCE hInstance);
	bool StopComponents();

	HINSTANCE hInstance;
	HMENU trayMenu;
	NOTIFYICONDATA notifyIconData;
	HWND hWnd;
	BOOL dwmEnabled;

	bool closed;

	Scheduler * scheduler;
	DeskNotes * deskNotes;
	AdvancedShowDesktop * advancedShowDesktop;
	DeskTidy * deskTidy;
	DesktopPictureFrame * desktopPictureFrame;
	WindowTools * windowTools;


	static UINT WM_TASKBARCREATED;
	static CassiopeiaMain* instance;
	static HWINEVENTHOOK hWinEventHook;

	static void SchedulerActiveChanged(CassiopeiaComponent* sender, bool active);
	static void DeskNotesActiveChanged(CassiopeiaComponent* sender, bool active);
	static void AdvancedShowDesktopActiveChanged(CassiopeiaComponent* sender, bool active);
	static void DeskTidyActiveChanged(CassiopeiaComponent* sender, bool active);
	static void WindowToolsActiveChanged(CassiopeiaComponent* sender, bool active);
	static void desktopPictureFrame_ActiveChanged(CassiopeiaComponent* sender, bool active);
	
	static LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
	static VOID CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook,DWORD dwEvent,HWND hWnd,LONG idObject,LONG idChild,DWORD idEventThread,DWORD dwmsEventTime);
	static BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM lParam);	
};

#endif